{% extends "noinfo/base.html" %}

{% block title %}详细{% endblock %}

{% block content %}
    <form method="post">
        {% csrf_token %}
        <!-- <select id="s1" name="theme">
            {% for i in option %}
            <option value="{{ i }}">{{ i }}</option>
            {% endfor %}
        </select> -->
        <input type="text" name="theme">
        <button type="submit">筛选</button>
    </form>

    <table>
        <tr class="detail_head">
            <th>主题</th>
            <th>名称</th>
            <th>标题</th>
            <th>集数</th>
            <th>开始集数</th>
            <th>结束集数</th>
            <th>开播日期</th>
            <th>完播日期</th>
        </tr>
        {% for i in text %}
        <tr class="detail_text">
            <td>{{ i.theme }}</td>
            <td>{{ i.name }}</td>
            <td>{{ i.subtitle }}</td>
            <td class="num">{{ i.episodes }}</td>
            <td class="num">{{ i.episode_start }}</td>
            <td class="num">{{ i.episode_end }}</td>
            <td class="date">{{ i.date_start }}</td>
            <td class="date">{{ i.date_end }}</td>
        </tr>
        {% endfor %}
    </table>

    <script>
        var num_elements = document.getElementsByClassName("num");
        for(var n = 0; n<num_elements.length; n++){
            if(num_elements[n].innerHTML == 'None'){
                num_elements[n].innerHTML = '';
            }
        }

        var date_elements = document.getElementsByClassName("date");
        for(var i = 0; i<date_elements.length; i++){
            var d = new Date(date_elements[i].innerHTML);
            var y = d.getFullYear();
            var m = d.getMonth() + 1;
            if(m < 10){
                m = '0' + m;
            }
            var day = d.getDate();
            if(day < 10){
                day = '0' + day;
            }
            if(y){
                date_elements[i].innerHTML = y + '-' + m + '-' + day;
            }else{
                date_elements[i].innerHTML = '';
            }  
        }

    </script>
{% endblock %}